package zky.medicalInstitute;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;


public class MainActivity extends AppCompatActivity {
    private LinearLayout cECG_Layout;
    private LinearLayout Oxygen_Layout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //初始化控件，并触发点击跳转事件
        initUI();
    }

    /**
     * 初始化控件
     * 点击控件触发跳转事件
     */
    private void initUI() {
        cECG_Layout = findViewById(R.id.cECG_Layout);
        Oxygen_Layout = findViewById(R.id.Oxygen_Layout);
        cECG_Layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //跳转至心电呼吸测量界面

//                Intent intent = new Intent();
//                intent.setClass(MainActivity.this,cECGChartActivity.class);
//                startActivity(intent);
                //先跳转到蓝牙连接界面
                Intent intent = new Intent();
                intent.setClass(MainActivity.this,bleActivity.class);
                startActivity(intent);
            }
        });
        Oxygen_Layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //跳转至血氧脉搏测量界面
                Intent intent = new Intent();
                intent.setClass(MainActivity.this,OxgenChartActivity.class);
                startActivity(intent);
            }
        });
    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {

        switch (item.getItemId()) {
            case R.id.ble:
                Intent bleIntent = new Intent(this, bleActivity.class);
                startActivity(bleIntent);
                break;

        }
        return super.onOptionsItemSelected(item);
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater menuInflater = new MenuInflater(this);
        menuInflater.inflate(R.menu.blemenu,menu);
        return super.onCreateOptionsMenu(menu);
    }

}